package com.edward.mvpdemo.presenter;

import com.edward.mvpdemo.model.DataModelImpl;
import com.edward.mvpdemo.model.IDataModel;
import com.edward.mvpdemo.model.OnLoadDataListener;
import com.edward.mvpdemo.view.IMainView;

import java.util.List;

/**
 * Created by Administrator on 2016/4/28.
 */
public class IDataPresenterImpl implements IDataPresenter, OnLoadDataListener {
    private IDataModel dataModel;
    private IMainView mainView;

    public IDataPresenterImpl(IMainView mainView) {
        this.mainView = mainView;
        this.dataModel = new DataModelImpl();
    }

    @Override
    public void getData(int start) {
        dataModel.loadData(start, this);
    }

    @Override
    public void onSuccess(List data) {
        //加载成功
        mainView.setmData(data);
        mainView.showSuccess();
    }

    @Override
    public void onLoading() {
        mainView.showLoading();
    }

    @Override
    public void onError(String error) {
        mainView.showError(error);
    }
}
